/*
 * TestCallback.java
 *
 * Created on April 5, 2007, 5:55 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package vendingMachine.localLogger;

import java.io.Serializable;
import commpackage.SessionCallback;

/**
 *
 * @author Anne Harmeson
 */
public class LocalLoggerCB extends SessionCallback
{
    private boolean stop;
    
    /** Creates a new instance of Callback */
    public LocalLoggerCB ()
    {
        stop = false;
    }
    
    public boolean NeedStop() 
    {
        return stop; 
    }
    
    public void onSendError (int message_id, String message, boolean dropped_connection)
    {
        synchronized (this)
        {
            System.out.println ("Send Error " + message);
        }
    }
    
    public void onReceiveError (int message_id, String message, boolean dropped_connection )
    {
        synchronized (this)
        {
            System.out.println ("Receive Error " + message);
        }
    }
    
    public void onReceive ( int message_id, Serializable obj )
    {
        synchronized (this)
        {
            //Cast serializable object back to its type
            String str = (String)obj;
            System.out.println ("Object Returned was " + str);
            stop = true;
        }
    }
}